// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import './assets/js/appback.js'
import 'lib-flexible'
import 'babel-polyfill'
Vue.config.productionTip = false
/* eslint-disable no-new */
//接口 拦截
import http from './api/http'
import config from './api/config'
Vue.prototype.$http = http;
global.config = config;

import  FastClick  from  'fastclick'
FastClick.attach(document.body);

// import cookie from './assets/js/cookie'
// global.cookie = cookie;
import VueClipboard from 'vue-clipboard2'
VueClipboard.config.autoSetContainer = true;
Vue.use(VueClipboard)

import {DatetimePlugin, ConfirmPlugin, LoadingPlugin, ToastPlugin, AlertPlugin } from 'vux'
Vue.use(DatetimePlugin)
Vue.use(ConfirmPlugin)
Vue.use(LoadingPlugin)
Vue.use(ToastPlugin)
Vue.use(AlertPlugin)
Vue.prototype.$toast = function (text) {
    this.$vux.toast.text(text,'middle')
}

Vue.prototype.$login = function (callback) {
    if(!localStorage.getItem('token')){
        this.$toast('请先登录')
        setTimeout(()=> {
            this.$router.push({
                path:"/login"
            },600)
        })
        return;
    }else{
        callback()
    }
}
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
